package com.algorithm;


/**
 * 验证回文串
 */
public class YanZhengHuiWenChuanByLeetcodeSolution {

    public static boolean isPalindrome(String s) {
        StringBuilder stringBuilder=new StringBuilder();
        for (int i=0;i<s.length();i++){
            char c = s.charAt(i);
            if (Character.isLetterOrDigit(c)){
                stringBuilder.append(c);
            }
        }
        return stringBuilder.toString().equalsIgnoreCase(stringBuilder.reverse().toString());
    }

    public static void main(String[] args) {
        String str="A man, a plan, a canal: Panama";
        boolean result = isPalindrome(str);
        System.out.println(result);
    }
}
